package com.yf.socket;

import com.yf.im.netty.WsServer;
import com.yf.service.MsgCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
@PropertySource({"classpath:im.properties"})
public class SocketServer {

    @Autowired
    private Environment env;

    @Autowired
    private MsgCenterService msgCenterService;

    @PostConstruct
    public void start() throws InterruptedException {
        WsServer wsServer = new WsServer();
        wsServer.start(Integer.valueOf(env.getProperty("im.port")),msgCenterService).channel().closeFuture();
    }

}
